//
//  Team9AlbumTableViewCell.m
//  Team9Project
//
//  Created by dllo on 15/10/15.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9AlbumTableViewCell.h"
#import <Masonry.h>

#define WID 375.0
//#define HEI 667.0

@implementation Team9AlbumTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    self.albumImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.albumImageView];
    
    self.upImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upImageView];
    
    self.downImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.downImageView];
    
    self.titleLabel = [[Team9BaseLabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:14 / WID * WIDTH];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.numberOfLines = 0;
    
    self.liked_countImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.liked_countImageView];
    
    self.liked_countLabel = [[Team9BaseLabel alloc] init];
    self.liked_countLabel.font = [UIFont systemFontOfSize:14 / WID * WIDTH];
    [self.contentView addSubview:self.liked_countLabel];
    
    self.author_faceImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.author_faceImageView];
    self.author_faceImageView.layer.cornerRadius = 12.5 / WID * WIDTH;
    self.author_faceImageView.layer.masksToBounds = YES;
    
    self.author_nickLabel = [[Team9BaseLabel alloc] init];
    self.author_nickLabel.font = [UIFont systemFontOfSize:14 / WID * WIDTH];
    [self.contentView addSubview:self.author_nickLabel];

}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self.albumImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(110 / WID * WIDTH));
        make.left.top.equalTo(self.contentView).offset(10 / WID * WIDTH);
        
    }];
    
    [self.upImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.albumImageView.mas_right).offset(6 / WID * WIDTH);
        make.top.equalTo(self.albumImageView);
        make.width.height.equalTo(@(52 / WID * WIDTH));
    }];
    
    [self.downImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.height.equalTo(self.upImageView);
        make.top.equalTo(self.upImageView.mas_bottom).offset(6 / WID * WIDTH);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.upImageView);
        make.left.equalTo(self.upImageView.mas_right).offset(6 / WID * WIDTH);
        make.width.equalTo(@(180 / WID * WIDTH));
        make.height.equalTo(@(50 / WID * WIDTH));
    }];
    
    [self.liked_countImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.upImageView.mas_right).offset(6 / WID * WIDTH);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(6 / WID * WIDTH);
        make.width.height.equalTo(@(25 / WID * WIDTH));
    }];
    
    [self.author_faceImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.downImageView.mas_right).offset(6 / WID * WIDTH);
        make.width.height.equalTo(@(25 / WID * WIDTH));
        make.bottom.equalTo(self.albumImageView);
    }];
    
    [self.liked_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.liked_countImageView.mas_right).offset(6 / WID * WIDTH);
        make.top.height.equalTo(self.liked_countImageView);
        make.width.equalTo(@(100 / WID * WIDTH));
    }];
    
    [self.author_nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.equalTo(self.liked_countLabel);
        make.bottom.equalTo(self.downImageView);
        make.width.equalTo(self.titleLabel);
    }];
    
}

@end
